﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace 每日时间作息
{
    /// <summary>
    /// Window_Setttings.xaml 的交互逻辑
    /// </summary>
    public partial class Window_Setttings : Window
    {
        public Window_Setttings(Window owner=null)
        {
            InitializeComponent();
            if(owner!=null)
                this.Owner = owner;

            this.Topmost = true;
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Properties.Settings.Default.Save();
            this.Close();
        }

        private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            TextBox TextBox = sender as TextBox;
            if (TextBox == null) return;
            if (!System.Text.RegularExpressions.Regex.IsMatch(TextBox.Text, "^[0-2][0-9]:[0-5][0-9]$"))
            {
                TextBox.Text = "00:00";
            }
        }

        private void Window_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                this.DragMove();
            }
        }
    }
}
